#!/usr/bin/python
# -*- coding: UTF-8 -*-

from __future__ import print_function   # print('hello',end = ' ')
import random
# secret = random.randint(0,3)  #这是一个闭区间

name = (u'夏立军 - 斐波那契数列 -')
print(name)

# 迭代
def Num(x):
    tmp = [1, 1]
    while x > 2:
        tmp[0],tmp[1] = tmp[1] , tmp[0] + tmp[1]
        x -= 1
        print('%d --> %d' % (tmp[0],tmp[1]))
    return tmp[1]

print(u'迭代实现: %d' % Num(9))

# 递归
def fab(n):
    if n < 1:
        print(u'你输入的有误!')
        return -1
    if n==1 or n==2:
        return 1
    else:
        return fab(n-1)+fab(n-2)

res = fab(9)
if res != -1:
    print(u'递归实现: %d' % res)

